﻿using System;
using Microsoft.Extensions.Logging;

namespace Micro.Extensions.Data
{
    public static class DataLogExtensions
    {
        /// <summary>
        /// 数据访问日志
        /// </summary>
        private static readonly EventId DataEventId = new EventId(-113, "DataAccess");
        /// <summary>
        /// 警告日志
        /// </summary>
        /// <param name="logger">logger</param>
        /// <param name="message">消息</param>
        /// <param name="exception">异常</param>
        internal static void LogDataWarn(this ILogger logger, string message, Exception exception = null)
        {
            logger.Log(LogLevel.Warning, DataEventId, message, exception, (m, e) => m?.ToString());
        }
        /// <summary>
        /// Debug 日志
        /// </summary>
        /// <param name="logger">logger</param>
        /// <param name="message">消息</param>
        /// <param name="exception">异常</param>
        internal static void LogDataDebug(this ILogger logger, string message, Exception exception = null)
        {
            logger.Log(LogLevel.Debug, DataEventId, message, exception, (m, e) => m?.ToString());
        }
    }
}
